<div class="mainbox">
    <div class="ginfo">
        <div class="gtitle">{{goods_detail.goods_name}}</div>
        <egoodsdetail
        ></egoodsdetail>
    </div>
    <div class="bottomblock"></div>
    <div class="tobuy">
    	<input type="number" value="1" class="num" bind-input="{{'$Cache.goods_details.buy_number'}}" />
    	{{#if goods_detail.num}}
			<button event-click="{{'$Event.goods.add_to_cart'}}">立即购买</button>
    	{{#else}}
			<button class="disable" disabled="true">暂时缺货</button>
    	{{/if}}
    </div>
</div>
<div class="buyblock {{checkAdd&&'focus'}}">
	<div class="text">
        {{#if loginer}}
		<p>您购买的商品已添加到购物车，您可以</p>
		<a event-click="{{'$Event.checkAdd'}}">继续购买</a>
		<a href="#default/cart" event-click="{{'$Event.checkAdd'}}">查看购物车</a>
        {{#else}}
        <p>您还没有登陆，请选择</p>
        <a href="#default/sign?cb_url=1" event-click="{{'$Event.checkAdd'}}">登陆</a>
        <a event-click="{{'$Event.checkAdd'}}">取消</a>
        {{/if}}
	</div>
</div>

<xmp type="tag" name="egoodsdetail">
    <div class="goodsimgs">
        <div class="movebox">
            <div class="bigimgbox">
                {{#if goods_detail.detail_img_urls.length}} {{#each goods_detail.detail_img_urls}}
                <img class="bigimg" name="{{$Index}}" bind-src="{{$This}}?imageView/2/w/300" />{{/each}} {{#else}}
                <img class="bigimg" src="images/imgerror.jpg" />{{/if}}
            </div>
        </div>
        <div class="smallimgbox">
        	{{#if goods_detail.detail_img_urls.length}} {{#each goods_detail.detail_img_urls }}
			<img name="{{$Index}}" class="smallimg" bind-src="{{$This}}?imageView/1/w/50/h/50" />{{/each}} {{#else}}此商品卖家没有上传图片{{/if}}
        </div>
        
        <div class="item">
        	<div class="i price">￥{{goods_detail.price+"/"+goods_detail.unit}}</div>
        	<div class="i">库存：{{goods_detail.num}}</div>
        </div>
        <hr/>
        <div class="item">
        	{{goods_detail.intro}}
        </div>
    </div>
    <script type="text/vm">
    function(vm){
    	var moveimg=vm.queryElement({
    		className:"bigimgbox"
    	})[0];
    	require(['jQuery'],function($){
    		var w=$(document).width();
			$('.smallimgbox').on("click", "img", function() {
				$(moveimg).stop().animate({
					marginLeft: -w * $(this).attr('name')
				}, 350);
			})
    	})
    }
    </script>
</xmp>
